package com.tgy.myplus.基础学习.Thread.Normal;

/**
 * @author 送你一块二向箔
 * @date 2021/11/08 11:23
 */

/*
测试礼让线程，礼让不一定成功
 */
public class ThreadYield implements Runnable {
    @Override
    public void run() {
        System.out.println(Thread.currentThread().getName()+"线程开始");
        Thread.yield();//礼让
        System.out.println(Thread.currentThread().getName()+"线程停止");
    }

    public static void main(String[] args) {
        ThreadYield threadYield = new ThreadYield();
        new Thread(threadYield,"a").start();
        new Thread(threadYield,"b").start();
    }
}
